feat: stream transcription progress via SSE#5
Open
randroid88 wants to merge 1 commit into
Open
Conversation
Replace fire-and-forget POST /transcribe with a new SSE endpoint POST /transcribe/stream that emits stage-by-stage progress events (model load, VAD, transcribe, align). The frontend reads the stream and displays the current stage label alongside the percentage. The original /transcribe endpoint is preserved for backward compatibility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /transcribe/streamSSE endpoint that emits stage-by-stage progress events during transcriptionPOST /transcribeendpoint is preserved for backward compatibilityBefore
The progress bar showed a generic "Transcribing... X%" with no percentage updates until completion — the user had no idea which stage the pipeline was in.
After
Real-time stage labels with approximate progress:
Implementation
Backend: The SSE endpoint runs transcription in a thread executor. A
progress_cb(pct, label)callback is threaded throughtranscribe_audio()→_transcribe_whisperx(), emitting progress at each pipeline stage. Events are serialized asdata: {json}\n\nSSE format.Frontend: The
transcribeVideofunction reads the SSE stream with aReadableStreamreader, parsing each line for progress/label/result events.Files changed
backend/routers/transcribe.py— New/transcribe/streamendpoint with SSE streamingbackend/services/transcription.py— Addprogress_cbparameter, emit stage progressfrontend/src/App.tsx— SSE reader intranscribeVideo(),transcriptionLabelstate, updated progress displayTest plan
/transcribeendpoint still works (backward compatibility)